#include <algorithm>
#include <iostream>
#include <string>

#define lld long long
#define ENDL '\n'
#define mod %
#define LOG(var) std::cout << #var << " = " << (var) << ENDL

using std::cin;
using std::cout;
using std::min;
using std::string;

void solve() {
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int RG = 0, GB = 0, BR = 0;
  int RB = 0, GR = 0, BG = 0;

  for (int i = 0; i < n; ++i) {
    char x = s[i], y = t[i];
    if (x == 'R' && y == 'G') {
      RG++;
    } else if (x == 'R' && y == 'B') {
      RB++;
    } else if (x == 'G' && y == 'B') {
      GB++;
    } else if (x == 'G' && y == 'R') {
      GR++;
    } else if (x == 'B' && y == 'G') {
      BG++;
    } else if (x == 'B' && y == 'R') {
      BR++;
    }
  }

  // 直接交换
  int x = min(RG, GR);
  int y = min(RB, BR);
  int z = min(GB, BG);
  int opt = x + y + z;
  // LOG(opt);
  RG -= x;
  GR -= x;

  RB -= y;
  BR -= y;

  GB -= z;
  BG -= z;

  // 轮换交换
  int cycle1 = min(RG, min(GB, BR));
  opt += 2 * cycle1;
  RG -= cycle1;
  GB -= cycle1;
  BR -= cycle1;

  int cycle2 = min(RB, min(BG, GR));
  opt += 2 * cycle2;
  RB -= cycle2;
  BG -= cycle2;
  GR -= cycle2;

  // 剩余
  opt += RG + RB + GR + GB + BR + BG;
  cout << opt << ENDL;
}

int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
/*
input
3
RRR
BBB
RRG
RGR
RBG
BGR

output
3
1
2
*/